<?php
class BlockFactory implements Factory{

	const BLOCK_PREFIX = "Block_";
	/**
	 * (non-PHPdoc)
	 * @see library/Factory/Factory::getInstance()
	 * @param ControllerRoute $route
	 * @return Controller
	 */
	public function getInstance($route){
		return null;
	}
	/**
	 * Get BlockHelper by Class ...
	 * @param string $context
	 * @return BlockHelper
	 */
	public static function instance($context){
		$blockPath = BLOCK_PATH . SLASH . $context .'.php';
		if(file_exists($blockPath)){
			include_once $blockPath;
			$class = BlockFactory::BLOCK_PREFIX . $context;
			if(!class_exists($class)){
				Log::error("BlockFactory", "Class " . $class . " Not found");
				if(Configuration::DEBUG_MOD)
				throw new BlockException("Class " . $class . " Not found");
				return new BlockHelper();
			}
			return new $class;
		}
		else {
			Log::error("EntityFactory", "File " . $blockPath . " Not found");
			if(Configuration::DEBUG_MOD)
			throw new BlockException("Class " . $blockPath . " Not found");
			return new BlockHelper();
		}
	}
}